from core.dependencies import Base
from sqlalchemy import Column, Integer, String, Text, DateTime, func, ForeignKey
from pgvector.sqlalchemy import Vector
import uuid


class TextVector(Base):
    __tablename__ = 'text_vector'
    __table_args__ = {"schema": "public"}

    uid = Column(Integer, primary_key=True, index=True, autoincrement=True)
    vector_id = Column(String(32), default=lambda: uuid.uuid4().hex, nullable=False, unique=True, index=True)

    text_content = Column(Text, nullable=False)
    text_vector = Column(Vector(768), nullable=False)

    file_id = Column(String(32), nullable=False)
    file_name = Column(String(255), unique=False, nullable=False)
    know_base_id = Column(String(32), nullable=False)

    create_date = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
    user_id = Column(String(255), nullable=False, default='000000000000000000000000')

    def __repr__(self):
        return f"<TextVector(vector_id={self.vector_id}, file_id={self.file_id})>"


class ImageVector(Base):
    __tablename__ = 'image_vector'
    __table_args__ = {"schema": "public"}
    uid = Column(Integer, primary_key=True, index=True, autoincrement=True)
    vector_id = Column(String(32), default=lambda: uuid.uuid4().hex, nullable=False, unique=True, index=True)

    image_path = Column(String(255), unique=True, nullable=False)
    image_vector = Column(Vector(768), nullable=False)

    image_desc = Column(Text, nullable=True)
    desc_vector = Column(Vector(768), nullable=False)

    file_id = Column(String(32), nullable=False)
    file_name = Column(String(255), unique=False, nullable=False)
    know_base_id = Column(String(32), nullable=False)

    create_date = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
    user_id = Column(String(255), nullable=False, default='000000000000000000000000')

    def __repr__(self):
        return f"<ImageVector(vector_id={self.vector_id}, file_id={self.file_id},image_path = {self.image_path})>"